package cn.mymall.service.mall.impl;

import cn.mymall.entity.mall.Picture;
import cn.mymall.mapper.PictureMapper;
import cn.mymall.service.mall.IPictureService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liqilun
 * @since 2021-07-23
 */
@Service
public class PictureServiceImpl extends ServiceImpl<PictureMapper, Picture> implements IPictureService {

    @Override
    public List<Picture> findByProductIdOrderBySortNum(Integer productId) {
        return list(new QueryWrapper<Picture>().eq("product_id", productId).eq("sort_num", true));
    }

    @Override
    public int countByProductId(Integer productId) {
        return count(new QueryWrapper<Picture>().eq("product_id", productId));
    }
}
